package com.cxm.weilai.util;

/**
 * 利用ThreadLocal解决线程安全问题
 * @author tao
 */
public class CustomerContextHolder {
    public static final String DATA_SOURCE_A = "dataSourceOne";
    public static final String DATA_SOURCE_B = "dataSourceTwo";

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public CustomerContextHolder() {}

    public CustomerContextHolder(String data) {
        contextHolder.set(data);
    }

    /**
     * 设置CustomerType
     */
    public static void setCustomerType(String customerType) {
        contextHolder.set(customerType);
    }

    /**
     * 得到CustomerType
     */
    public static String getCustomerType() {
        return contextHolder.get();
    }

    public static void clearCustomerType() {
        contextHolder.remove();
    }
}
